<%@ page contentType="text/html; charset=UTF-8" 
import="java.util.*,com.admin.User,com.admin.Role"

%> <% User user=(User)request.getSession().getAttribute("login_user");
    Role role=(Role)request.getSession().getAttribute("user_roles");
 %><%@ taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
%>
    <link href="<%=path%>/bgstyle/misc/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
	<link href="<%=path%>/bgstyle/misc/css/bootstrap-modal.css" rel="stylesheet" type="text/css" />
	<link href="<%=path%>/bgstyle/misc/css/joywindow.bootstrap.css" rel="stylesheet" type="text/css" />
	
	<script type="text/javascript" src="<%=path%>/bgstyle/misc/js/jquery-1.7.2.js"></script>
	<script type="text/javascript" src="<%=path%>/bgstyle/misc/js/bootstrap.js"></script>	
	<script type="text/javascript" src="<%=path%>/bgstyle/misc/js/bootstrap-modalmanager.js"></script>	
	<script type="text/javascript" src="<%=path%>/bgstyle/misc/js/bootstrap-modal.js"></script>
	<script type="text/javascript" src="<%=path%>/bgstyle/misc/js/modal.manager.plugin1.0.js"></script>
		<script type="text/javascript" src="<%=path%>/bgstyle/misc/js/jquery.ui.draggable.js"></script>

	<!-- you can delete follow resource 以下两个可删除-->
	<script type="text/javascript" src="<%=path%>/bgstyle/misc/js/form.validate.js"></script>
	<script type="text/javascript" src="<%=path%>/bgstyle/misc/js/jshow.utils.js"></script>	
	
	<script type="text/javascript" src="<%=path%>/bgstyle/misc/other/prettify.js"></script>
	<link href="<%=path%>/bgstyle/misc/other/prettify.css" rel="stylesheet" type="text/css" />
 <body>
	
			<form class="form-horizontal"  id="form1">
			
				 <div class="control-group">
					<label class="control-label" for="yhzh">用户账号</label>
					<div class="controls">
						     <input type="text" id="yhzh" value="${session.login_user.usercode}" disabled>
                    </div>
				</div>
				
				 <div class="control-group">
					<label class="control-label" for="username">用户姓名</label>
					<div class="controls">
					     <input type="text" id="username" value="${session.login_user.username}" disabled>
                                        
					</div>
				</div>
				
				 <div class="control-group">
					<label class="control-label" for="pwd">当前密码</label>
					<div class="controls">
					<input  type="password" id="pwd" >
					<input type="hidden" id="truepw" value="${session.login_user.password}" >
                    </div>
				</div>
				
				 <div class="control-group">
					<label class="control-label" for="pwdnew">新密码</label>
					<div class="controls">
					   <input  type="password" id="pwdnew">
					</div>
				</div>
				
				 <div class="control-group">
					<label class="control-label" for="twopwd">确认新密码</label>
					<div class="controls">
					 <input type="password" id="twopwd" >
					</div>
				</div>
				
				 
				 <div class="control-group">
				 <div class="controls">
				<a href="javascript:;" class="btn btn-primary" id="btn_submit">确定</a>
				</div></div>
			</form>
		

		<script type="text/javascript">
		void function(j) {
			var validateSet = {
				 
					pwd:  {must: true, minlength:3,maxlength:20,ftip:'必输项'},
					pwdnew:  {must: true, minlength:3,maxlength:20,ftip:'必输项'},
					twopwd:  {must: true,minlength:1, maxlength:20,equalTo:'pwdnew',ftip:'必输项'}

			};
			

			j('#btn_submit').click(function(e) {
				if(form.validate(validateSet)){
					 var pwd 	= document.getElementById("pwd");
					 var newpwd 	= document.getElementById("pwdnew");
					 var twopwd	= document.getElementById("twopwd");
					 var code 	= document.getElementById("yhzh");
					 $.ajax({
			 	  			
			 				dataType: "json",
			 				type: "POST",
			 				url: "<%=path%>/admin/passwordmod",
			 				data: {
			 					"newpassword":newpwd.value,
			 					"password":pwd.value,
			 					"usercode":code.value
			 				},success: function(req) {	
			 					  
								gDialog.fAlert(req.msg);
			 				    $("#pwd").val("");
			 				    $("#pwdnew").val("");
			 				    $("#twopwd").val("");
			 				},error: function(){ 
			 					gDialog.fAlert('服务器错误，请稍后再试'); 

			 	 				}
			 			});
					
					
					
					
				   
				}
			});
			
			form.friend.init(validateSet);
		}(jQuery);
		</script>
		
		
		
 
 </body>
</html>
